package top.infopub.enums.bpa;

import org.apache.commons.lang3.StringUtils;
import top.infopub.enums.mkt.BackMechEnum;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author: Tszzzzzz
 * @Date: 2021/6/15
 */
public enum  CalPriceEnum {
    CAL_TYPE1("1", "清单"),
    CAL_TYPE2("2", "定额"),
    CAL_TYPE3("3", "固定总价"),
    CAL_TYPE4("4", "综合"),
    CAL_TYPE5("5", "其他");

    private String code;

    private String name;

    CalPriceEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static CalPriceEnum getByCode(String code) {
        if (StringUtils.isBlank(code)) return null;
        for (CalPriceEnum bme : CalPriceEnum.values()) {
            if (StringUtils.equals(code, bme.getCode())) {
                return bme;
            }
        }
        return null;
    }

    public static List<Map<String, String>> asList() {
        List<Map<String, String>> list = new ArrayList<>();
        Map<String, String> map;
        for (CalPriceEnum bme : CalPriceEnum.values()) {
            map = new HashMap<>();
            map.put("code", bme.getCode());
            map.put("name", bme.getName());
            list.add(map);
        }
        return list;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
